package com.example.day4;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    TextView text,text2;
    EditText edit;
    RadioGroup rg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        text = findViewById(R.id.textView);
        text2=findViewById(R.id.textView2);
        edit = findViewById(R.id.edit_text1);
        rg=findViewById(R.id.rg);
        text.setText("1702NB");
        text.setTextColor(Color.argb(255,255,0,0));
        String aa =edit.getText().toString();
        text.setText(aa);
        text.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "你点击了按钮1111", Toast.LENGTH_LONG).show();
                String aa =edit.getText().toString();
                text.setText(aa);
            }
        });
        text2.setOnClickListener(this);
        RadioButton rb = new RadioButton(this);
        rb.setText("aaaaaaa");
        RadioButton rb2 = new RadioButton(this);
        rb2.setText("bbbbbbbbbbbb");
        rg.addView(rb);
        rg.addView(rb2);
        Log.e("#######title","bottom");
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.textView:
                Toast.makeText(MainActivity.this, "你点击了按钮", Toast.LENGTH_LONG).show();
                String aa =edit.getText().toString();
                text.setText(aa);
                break;
            case R.id.textView2:
                Toast.makeText(MainActivity.this, "你点TMD击了按钮", Toast.LENGTH_LONG).show();
                String aa1 =edit.getText().toString();
                text.setText(aa1);
                break;
        }
    }

    class MyListener implements View.OnClickListener
    {
        //TODO 按钮点击的方法
        // View view  当前点击的控件
        @Override
        public void onClick(View view) {
            //吐司
            switch (view.getId()){
                case R.id.textView:
                    Toast.makeText(MainActivity.this, "你点击了按钮", Toast.LENGTH_LONG).show();
                    String aa =edit.getText().toString();
                    text.setText(aa);
                    break;
                case R.id.textView2:
                    Toast.makeText(MainActivity.this, "你点TMD击了按钮", Toast.LENGTH_LONG).show();
                    String aa1 =edit.getText().toString();
                    text.setText(aa1);
                    break;
            }

        }
    }

}
